package com.chuanghai.light.dao;

import com.chuanghai.light.entity.LightPoint;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface LightPointDao extends JpaRepository<LightPoint, String> {

    @Query(value = "select state from light_point WHERE point_code=?", nativeQuery = true)
    Boolean findStateByPointCode(String pointCode);

    @Query(value = "select online from light_point WHERE point_code=?", nativeQuery = true)
    Boolean findOnlineByPointCode(String pointCode);

    List<LightPoint> findAll();

    LightPoint findByPointCode(String pointCode);

    LightPoint findByIp(String ip);
}
